package com.supcon.tinyportal.tags;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class PrerenderTag extends BodyTagSupport {

	private static final long serialVersionUID = 1L;

	private boolean cached = false;

	public boolean isCached() {
		return cached;
	}

	public void setCached(boolean cached) {
		this.cached = cached;
	}

	public int doStartTag() throws JspException {
		HttpServletResponse response = (HttpServletResponse) (pageContext.getResponse());

		if (!cached) {
			response.setHeader("Pragma", "No-cache");
			response.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
			response.setDateHeader("Expires", 1);
		}

		response.setContentType("text/xml");
		
		return EVAL_BODY_INCLUDE;
	}

	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
}
